from datetime import datetime

from sqlalchemy import Boolean, Column, Date, Double, ForeignKey, String, Text
from sqlalchemy.orm import declarative_base


class Files(declarative_base()):
    __tablename__ = "files"
    id = Column(String, primary_key=True)
    meta_id = Column(String, nullable=False)
    modality_id = Column(String, ForeignKey("modality.id"))
    s3_id = Column(String, ForeignKey("s3.id"))
    name = Column(String, nullable=False)
    size_in_mb = Column(Double, nullable=False)
    extension = Column(String, nullable=False)
    description = Column(Text, nullable=True)
    is_pathology = Column(Boolean, nullable=False)
    is_defected = Column(Boolean, nullable=True)
    is_marked = Column(Boolean, nullable=False)
    time_was_uploaded = Column(Date, nullable=False, default=datetime.now)
    time_was_checked = Column(Date, nullable=True)


class Modality(declarative_base()):
    __tablename__ = "modality"
    id = Column(String, primary_key=True)
    type_of_research = Column(String, nullable=False)
    name_of_modality = Column(String, nullable=False)
    name_of_organ = Column(String, nullable=False)
    name_of_disease = Column(String, nullable=False)
    type_of_data = Column(String, nullable=False)
    description = Column(Text, nullable=True)
    type_of_task = Column(String, nullable=False)


class S3(declarative_base()):
    __tablename__ = "s3"
    id = Column(String, primary_key=True)
    bucket = Column(String, nullable=False)
    path_to_s3 = Column(String, nullable=False)
